#!/usr/bin/perl -w
 
use strict;
use warnings;
 
# directory in which we look for movies to play
my $videos_path = '/Users/tod/Desktop/';

# readlink gets the actual path of the file
# that the symlink points to
#my $realpath = `readlink "$mediapath/current.mov"`;
#chomp $realpath;

# basename strips off the path
# and leaves just the filename
#my $realname = `basename "$realpath"`;
my $realname = "foo"; #`basename "$realpath"`;
#chomp $realname;

`osascript<<EOF
tell application "QuickTime Player"
   activate
   set show welcome movie automatically to false
   copy "" to movieName
   if number of movies > 0 then
      copy (name of front movie) to movieName
   end if
   if (movieName is not "$realname") then
      open POSIX file "$videos_path/current.mov"
      set looping of movie 1 to false
      present movie 1 scale screen
   else
      if (display state of front movie is not presentation) then
         present front movie scale screen
      end if
      if (playing of front movie is false) then
         play front movie
      end if
   end if
end tell
EOF`;


 
 
